/**
 * Author@ Cheng Feitian
 * Date: 2020-3-18
 * Description: 
 */

#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>

#define COUNT 5

using namespace std;

struct Student{
    string sName;
    int scope;
};

struct Teacher
{
    string tName;
    struct Student sArray[5];
};

void allocateSpace(struct Teacher tArray[],int len){

    const string nameSeed = "ABCDE";

    for(int i = 0;i < len;i++){
        tArray[i].tName = "Teacher_";
        tArray[i].tName += nameSeed[i];

        //通过循环给每名老师所带的学生赋值
        for (int j = 0; j < COUNT; j++)
        {
            tArray[i].sArray[j].sName = "Student_";
            tArray[i].sArray[j].sName += nameSeed[j];

            tArray[i].sArray[j].scope = (rand() % 61 + 40);
        }
    }
}

void printToScreen(const struct Teacher *tArray,int len){
    for (int i = 0; i < len; i++)
    {
        cout << "Teacher's name:" << tArray[i].tName << endl;
        cout << "The teacher's students as follows:" << endl;

        for (int j = 0; j < COUNT; j++)
        {
            cout << "\tStudent's name:" << tArray[i].sArray[j].sName << 
                    "Student's scope:" << tArray[i].sArray[j].scope << endl;
        }
        
    }
    
}

int main() {
#ifdef LOCAL
    freopen("./result/1.in", "r", stdin);
    freopen("./result/1.out", "w", stdout);
#endif
    //随机种子
    srand((unsigned int)time(NULL));
    //1. 创建三名老师的数组
    struct Teacher tArray[3];
    int len = sizeof(tArray) / sizeof(tArray[0]);
    //2. 通过函数给3名老师的信息赋值，并给老师带的学生信息
    allocateSpace(tArray,len);
    //3. 打印所有老师及所带的学生信息
    printToScreen(tArray,len);

    return 0;
}
